/**
* 模块名: 博客前台api归档
* 代码描述: 博客前台api归档
* 作者: gaoxinchuan
* 创建时间:2023/01/22 21:53:51
*/
import request from '@/utils/request'
import {
    Res,
    ResData,
    InLoginItf,
    OutLoginItf,
    InInsertLoginInfoItf,
    InCheckUserNameItf,
    InCheckUserEmailItf,
    InSendEmailItf,
    InRegisterItf,
    OutGetCarouselItf,
    OutGetAllArticleInfoItf,
    GetSystemSetupItf,
    GetArticleClassItf,
    InsertVisitInfoItf,
    GetTopTextITF,
    GetArticleByPageITF,
    GetCommentByArticleIdITF,
    ClassifyITF,
    GetWebsiteLinkItf,
    InsertWebSiteItf,
    GetMessageItf
} from './types'

// 登录
export function Login(data: InLoginItf): Promise<Res<OutLoginItf>> {
    return request({
        url: '/login/tologin',
        method: 'POST',
        data
    })
}
// 添加登录信息
export function InsertLoginInfo(data: InInsertLoginInfoItf): Promise<Res<unknown>> {
    return request({
        url: '/login/insertLoginInfo',
        method: 'POST',
        data
    })
}

// 验证用户名是否重复
export function CheckUserName(params: InCheckUserNameItf): Promise<Res<unknown>> {
    return request({
        url: 'user/showUserName',
        method: 'GET',
        params
    })
}

// 验证邮箱是否重复
export function CheckUserEmail(params: InCheckUserEmailItf): Promise<Res<unknown>> {
    return request({
        url: '/user/searchEmail',
        method: 'GET',
        params
    })
}

// 注册
export function Register(data: InRegisterItf): Promise<Res<unknown>> {
    return request({
        url: '/user/insertRegisterInfo',
        method: 'POST',
        data
    })
}

// 将验证码、用户输入的邮箱传给后台，发送给用户邮箱
export function SendEmail(params: InSendEmailItf): Promise<Res<unknown>> {
    return request({
        url: '/email/sendEmail',
        method: 'GET',
        params
    })
}

// 轮播图
export function GetCarousel(): Promise<ResData<OutGetCarouselItf>> {
    return request({
        url: '/carouseMap/searchCarouseMap',
        method: 'GET',
    })
}


// 查询全部文章
export function GetAllArticleInfo(): Promise<ResData<OutGetAllArticleInfoItf>> {
    return request({
        url: '/article/showAllArticleInfo',
        method: 'GET',
    })
}

// 查询系统设置
export function GetSystemSetup(): Promise<ResData<GetSystemSetupItf>> {
    return request({
        url: '/systemSetup/showAllSystemSetup',
        method: 'GET',
    })
}

// 查询文章分类
export function GetArticleClass(): Promise<ResData<GetArticleClassItf>> {
    return request({
        url: '/classify/showAllClassifyInfo',
        method: 'GET',
    })
}

// 查询过审文章数量
export function GetPassArticle(): Promise<Res<number>> {
    return request({
        url: '/article/showArticleCount',
        method: 'GET',
    })
}

// 保存访问信息
export function InsertVisitInfo(data: InsertVisitInfoItf): Promise<Res<unknown>> {
    return request({
        url: '/ip/insert',
        method: 'post',
        data
    })
}

// 查询循环字
export function GetTopText(params: { currentPage: number, pageSize: number }): Promise<Res<GetTopTextITF>> {
    return request({
        url: '/text/getall',
        method: 'GET',
        params
    })
}

// 分页请求文章
export function GetArticleByPage(params: { currentPage: number, pageSize: number, keyword: any }): Promise<Res<GetArticleByPageITF>> {
    return request({
        url: '/article/page/showAll',
        method: 'GET',
        params
    })
}

// 点击文章加1
export function AddClickNumber(params: { articleId: number }): Promise<Res<unknown>> {
    return request({
        url: '/article/updateArticleClick',
        method: 'GET',
        params
    })
}

// 文章评论
export function GetCommentByArticleId(params: { articleId: number }): Promise<ResData<GetCommentByArticleIdITF>> {
    return request({
        url: '/comment/showCommentByArticleId',
        method: 'GET',
        params
    })
}

// 根据分类id查询分类信息
export function GetClassifyInfoByClassifyId(params: { classifyId: any }): Promise<Res<ClassifyITF>> {
    return request({
        url: '/classify/showClassifyInfoByClassifyId',
        method: 'GET',
        params
    })
}

// 查分类文章
export function GetArticlebyClassifyId(params: { currentPage: number, pageSize: number, classifyId: any }): Promise<ResData<OutGetAllArticleInfoItf>> {
    return request({
        url: '/article/byClassifyId',
        method: 'GET',
        params
    })
}


// 查网站链接
export function GetWebsiteLink(params: { urlType: number }): Promise<Res<GetWebsiteLinkItf>> {
    return request({
        url: '/url/page/showAllUrlInfo',
        method: 'GET',
        params
    })
}

// 提交网站信息
export function InsertWebSite(data: InsertWebSiteItf): Promise<Res<unknown>> {
    return request({
        url: '/url/insert',
        method: 'POST',
        data
    })
}

// 查寻留言
export function GetMessage(params: { currentPage: number, pageSize: number }): Promise<GetMessageItf> {
    return request({
        url: '/message/pageShow',
        method: 'GET',
        params
    })
}

// 提交留言
export function InsertMessage(data: { messageName: string, messageQQ: string, content: string }): Promise<Res<unknown>> {
    return request({
        url: '/message/insert',
        method: 'POST',
        data
    })
}

// 删除留言
export function DeleteMessage(params: { messageId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/message/delete',
        method: 'DELETE',
        params
    })
}

// 回复留言
export function ReplayMessage(data: { messageId: number | string, replyContent: any }): Promise<GetMessageItf> {
    return request({
        url: '/message/updateMessageReply',
        method: 'POST',
        data
    })
}

// 删除评论
export function DeleteComment(params: { commentId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/comment/delete',
        method: 'DELETE',
        params
    })
}

// 回复评论
export function InsertCommentInfo(data: { articleId: number, userId: number, content: string, parentId: number }): Promise<Res<unknown>> {
    return request({
        url: '/comment/insertCommentInfo',
        method: 'POST',
        data
    })
}